package me.boot.common.condition;

import cn.hutool.core.util.StrUtil;
import me.boot.common.constant.Const;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 单体应用判断条件
 */
public class MonoAppCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String discoveryServerAddr = context.getEnvironment().getProperty(Const.CLOUD_SERVER_KEY);
        //如果没有服务注册发现的配置 说明是单体应用
        return StrUtil.isBlank(discoveryServerAddr);
    }
}
